<?php
$content_for_head .= <<<_HEAD_
<style type="text/css" media="screen">
/* <![CDATA[ */
    .acl_name {font-weight:bold}
    .acl_description {font-style:italic;color:#666;margin-left:20px;}
    .h_form {display:inline;margin:0;padding:0;}
    #acl_list {
        border:1px solid #eee;
        padding:5px;
        margin:5px auto;
    }
    #acl_list form {
        display:inline;
    }
    .an_acl {
        margin: 1px 0;
        padding:0.2em;
        padding-bottom:0.4em
    }
    
/* ]]> */
</style>
_HEAD_;
?>
<h1>Access Control List</h1>

<div id='error_messages' class='flash_error' style='display:none'></div>
<?php echo form_remote_tag('add',
             array(
                'update'=>'acl_list',
                'position'=>'Top',
                'scripts'=>true,
                'id'=>'access-form',
                )
                )?>
<?php echo hidden_field_tag('action','add')?>
<div id="add_new"> 
    <span style='color:red'>*</span> <b>Name:</b> 
    <?php echo text_field_tag('acl_name',
                                null,
                                array('class'=>'required')
                             );
    ?>
    <b>Description:</b> <?php echo text_field_tag('acl_description')?>
    <?php echo submit_tag('Add', array('onclick'=>validate_form('access-form', array('onSubmit'=>'false'), true)))?>
</div>
<?php echo end_form_tag()?>




<div id="acl_list">
    <?php

        if ( count($list) > 0 )
        {
            $oe = 0;
            foreach( $list as $l )
            {
                $oe = 1 - $oe;
                $form = form_remote_tag('delete',array('complete'=>"Element.hide('acl_{$l['id']}')")).
                        hidden_field_tag('id',$l['id']).
                        image_submit_tag('delete',
                                         '/images/admin/delete.gif',
                                         array('onclick'=>"return delete_confirm('acl_{$l['id']}')",
                                               'style'=>'border:0',
                                               'align'=>'absmiddle')
                                         ).
                        end_form_tag();
                printf('<div id="acl_%s" class="an_acl alt'.$oe.'">
                        %s
                        <span id="name_%s" class="acl_name">%s</span>&nbsp;&nbsp;&nbsp;&nbsp;
                        <span id="desc_%s" class="acl_description">%s</span></div>',
                        $l['id'],
                        $form,                        
                        $l['id'],
                        $l['acl_name'],
                        $l['id'],
                        $l['acl_description']);
                echo "<script type=\"text/javascript\">
                         new Ajax.InPlaceEditor('name_{$l['id']}', '".url_for('modify')."',".
                         "{callback: function(form,value){return 'action=edit&acl_name='+escape(value)+'&id={$l['id']}'}, ".
                         "ajaxOptions: {evalScripts:true}".
                         "});
                        </script>";
                echo "<script type=\"text/javascript\">
                         new Ajax.InPlaceEditor('desc_{$l['id']}', '".url_for('modify')."',".
                         "{callback: function(form,value){return 'action=edit&acl_description='+escape(value)+'&id={$l['id']}'}, ".
                         "ajaxOptions: {evalScripts:true}".
                         "});
                        </script>";
            }
        } else {
            echo '<p>No access controls specified yet.</p>';
        }

    ?>
</div>